﻿<!--
// ****************************************************************************
// <author>mishkin Ivan</author>
// <email>Mishkin_Ivan@mail.ru</email>
// <date>28.01.2015</date>
// <project>ItemsFilter</project>
// <license> GNU General Public License version 3 (GPLv3) </license>
// ****************************************************************************
-->
<UserControl x:Class="Northwind.NET.Sample.View.ProductsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:bsFilter="http://schemas.bolapansoft.com/xaml/Controls/ItemsFilter"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:Northwind.NET.Sample"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:model="clr-namespace:Northwind.NET.EF6Model;assembly=Northwind.NET.EF6Model"
             xmlns:vm="clr-namespace:Northwind.NET.Sample.ViewModel"
             xmlns:vw="clr-namespace:Northwind.NET.Sample.View"
             d:DesignHeight="373"
             d:DesignWidth="829"
             mc:Ignorable="d">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <vw:CategoryFilterView />
        <DataGrid x:Name="productDataGrid"
                  Grid.Row="1"
                  AutoGenerateColumns="False"
                  ItemsSource="{Binding Path=Products,
                                        Source={StaticResource Workspace}}">
            <DataGrid.Resources>
                <DataTemplate DataType="{x:Type model:Category}">
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </DataGrid.Resources>
            <DataGrid.Columns>

                <DataGridTextColumn x:Name="iDColumn"
                                    Width="Auto"
                                    Binding="{Binding ID}"
                                    Header="ID" />
                <DataGridTextColumn x:Name="supplier"
                                    Width="Auto"
                                    Binding="{Binding Supplier.Name}"
                                    Header="Supplier" >
                    <bsFilter:ColumnFilter.Initializers>
                        <vw:SupplierNameFIM/>
                    </bsFilter:ColumnFilter.Initializers>
                </DataGridTextColumn>
                <DataGridTextColumn x:Name="nameColumn"
                                    Width="Auto"
                                    Binding="{Binding Name}"
                                    Header="Name" />
                <DataGridTextColumn x:Name="categoryColumn"
                                    Width="Auto"
                                    Binding="{Binding Category.Name}"
                                    Header="Category"
                                    IsReadOnly="True"
                                    bsFilter:ColumnFilter.BindingPath="Category" />
                <DataGridCheckBoxColumn x:Name="discontinuedColumn"
                                        Width="Auto"
                                        Binding="{Binding Discontinued}"
                                        Header="Discontinued" />
                <DataGridTextColumn x:Name="reorderLevelColumn"
                                    Width="Auto"
                                    Binding="{Binding ReorderLevel}"
                                    Header="Reorder Level" />
                <DataGridTextColumn x:Name="unitPriceColumn"
                                    Width="150"
                                    Binding="{Binding UnitPrice,
                                                      StringFormat=\{0:F2\}}"
                                    Header="Unit Price">
                    <bsFilter:ColumnFilter.Initializers>
                        <bsFilter:FilterInitializersManager>
                            <vm:UnitPriceFilterInitializer />
                            <vm:UnitPriceRangeFilterInitializer />
                        </bsFilter:FilterInitializersManager>
                    </bsFilter:ColumnFilter.Initializers>
                </DataGridTextColumn>


            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
